package com.fz.us.oa.core.entity.com;

import com.fz.us.admin.company.entity.BaseFlowEntity;
import com.fz.us.admin.company.entity.User;
import com.fz.us.admin.dict.entity.DictItem;
import com.fz.us.oa.core.entity.common.FileManage;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 业务实体类 - 任务发起登记表
 * ============================================================================
 * 版权所有 2017 。
 *
 * @author XuHeng
 * @version 1.0 2017-02-09 。
 * ============================================================================
 */
@Entity
@Table(name="ec_task")
public class Task extends BaseFlowEntity {

    private static final long serialVersionUID = -4755591832055539865L;
    /**
     * 所属项目
     */
    private DictItem dictItem;
    /**
     * 关联任务
     */
    private Set<Task> relateTasks;

    /**
     * 任务名称 name
     */

    /**
     * 详细要求
     */
    private String detail;

    /**
     * 任务责任人
     */
    private Set<User> leaders;
    private String leadersIds;

    /**
     * 任务组员
     */
    private Set<User> members;

    /**
     * 计划开始时间
     */
    private Date datPlanStart;

    /**
     * 计划完成时间
     */
    private Date datPlanEnd;

    /**
     * 预警时间
     */
    private Date datWarning;

    /**
     * 优先程度 0:一般 1:重要 2:紧急
     */
    private int priority;

    /**
     * 相关附件
     */
    private List<FileManage> file;

    /**
     * 提交日期
     */
    private Date dateApply;
    /**
     * 文档状态数值
     */
    private int numStatus;
    /**
     * 文档状态文字
     */
    private String txtStatus;

    /**
     * 调整日期
     */
    private Date dateUpdate;
    /**
     * 文档调整UNID
     */
    private String updateUnid;

    /**
     * 表单名称
     */
    private String form;

    @Column(nullable=false, columnDefinition = "varchar(50) default '任务发起登记表'")
    public String getForm() {
        return form;
    }

    public void setForm(String form) {
        this.form = form;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public DictItem getDictItem() {
        return dictItem;
    }

    public void setDictItem(DictItem dictItem) {
        this.dictItem = dictItem;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    public Set<Task> getRelateTasks() {
        return relateTasks;
    }

    public void setRelateTasks(Set<Task> relateTasks) {
        this.relateTasks = relateTasks;
    }

    @Column(columnDefinition="text")
    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name="task_leader",
            joinColumns={@JoinColumn(name="task_id")},
            inverseJoinColumns={@JoinColumn(name="leader_id")}
    )
    public Set<User> getLeaders() {
        return leaders;
    }

    public void setLeaders(Set<User> leaders) {
        this.leaders = leaders;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name="task_member",
            joinColumns={@JoinColumn(name="task_id")},
            inverseJoinColumns={@JoinColumn(name="member_id")}
    )
    public Set<User> getMembers() {
        return members;
    }

    public void setMembers(Set<User> members) {
        this.members = members;
    }

    public Date getDatPlanStart() {
        return datPlanStart;
    }

    public void setDatPlanStart(Date datPlanStart) {
        this.datPlanStart = datPlanStart;
    }

    public Date getDatPlanEnd() {
        return datPlanEnd;
    }

    public void setDatPlanEnd(Date datPlanEnd) {
        this.datPlanEnd = datPlanEnd;
    }

    public Date getDatWarning() {
        return datWarning;
    }

    public void setDatWarning(Date datWarning) {
        this.datWarning = datWarning;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_task_file", joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="fileId"))
    public List<FileManage> getFile() {
        return file;
    }

    public void setFile(List<FileManage> file) {
        this.file = file;
    }

    public Date getDateApply() {
        return dateApply;
    }

    public void setDateApply(Date dateApply) {
        this.dateApply = dateApply;
    }

    public int getNumStatus() {
        return numStatus;
    }

    public void setNumStatus(int numStatus) {
        this.numStatus = numStatus;
    }

    public String getTxtStatus() {
        return txtStatus;
    }

    public void setTxtStatus(String txtStatus) {
        this.txtStatus = txtStatus;
    }

    public Date getDateUpdate() {
        return dateUpdate;
    }

    public void setDateUpdate(Date dateUpdate) {
        this.dateUpdate = dateUpdate;
    }

    public String getUpdateUnid() {
        return updateUnid;
    }

    public void setUpdateUnid(String updateUnid) {
        this.updateUnid = updateUnid;
    }

    @Type(type="text")
    public String getLeadersIds() {
        return leadersIds;
    }

    public void setLeadersIds(String leadersIds) {
        this.leadersIds = leadersIds;
    }
}
